package biz.sdna.generatecode.core;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.hibernate.cfg.reveng.DelegatingReverseEngineeringStrategy;
import org.hibernate.cfg.reveng.ReverseEngineeringStrategy;
import org.hibernate.cfg.reveng.SchemaSelection;
import org.hibernate.cfg.reveng.TableIdentifier;

public class ReverseEngineeringStrategyModel extends
		DelegatingReverseEngineeringStrategy {

	public static String CATALOG = "";
	public static String SCHEMA = "";
	public static String MODEL = "";
	public static String MODEL_REGEX = "";
	public static Map MODEL_TABLE = new HashMap();

	public ReverseEngineeringStrategyModel(ReverseEngineeringStrategy delegate) {
		super(delegate);
	}

	public List getSchemaSelections() {
		List list = new ArrayList();
		list.add(new SchemaSelection(CATALOG, SCHEMA));
		return list;
	}

	public boolean excludeTable(TableIdentifier ti) {
		if (!MODEL_TABLE.containsKey(MODEL)) {
			MODEL_TABLE.put(MODEL, new ArrayList());
		}
		if (ti.getName().matches(MODEL_REGEX)) {
			List listTable = (List) MODEL_TABLE.get(MODEL);
			listTable.add(ti.getName());
			return false;
		}
		return true;
	}
}
